home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
dax1.exe
/
DAP
/
DAP.H
< prev
next >
Wrap
Text File
|
1992-07-15
|
13KB
|
313 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: dap.h ║
// ║ ║
// ║ This software is provided as is and carries no warranty ║
// ║ whatsoever. Novell disclaims and excludes any and all implied ║
// ║ warranties of merchantability, title and fitness for a particular ║
// ║ purpose. Novell does not warrant that the software will satisfy ║
// ║ your requirements or that the software is without defect or error ║
// ║ or that operation of the software will be uninterrupted. You are ║
// ║ using the software at your risk. The software is not a product ║
// ║ of Novell, Inc. or any of subsidiaries. ║
// ║ ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ maintenance history: ║
// ║ level date pi description ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ 001 01/23/92 kl initial release. ║
// ╚════════════════════════════════════════════════════════════════════╝
#if !defined(DAPHEADER)
#define DAPHEADER
#if defined(ENGINE)
#include <nwtypes.h>
#elif defined(DOSCLIENT) || defined(WINCLIENT)
#include <nit.h>
#elif defined(NLMCLIENT)
#include <nwtypes.h>
#include <nwbindry.h>
#include <nwconn.h>
#include <process.h>
#endif
#include "h/extypes.h"
#include "dap/config.h"
#include "dap/dapdbg.h"
#define DAPSIGNATURE 0x20504144 // 'DAP ' signature value
//
// The following constants are used in the packetType field of a
// DAP Request or Reply packet.
//
//
// Future versions may support bi-directional requests, i.e.
// the client OR server can initiate a request. Since, both
// requests and replies are de-multiplexed off of the same virtual
// session, the packettype field is used to indicate what type
// of data has been received. The manifest constants below are
// valid 'packettype' values.
//
//!!
// Add a DAPCalloutAPI to the CP Layer so it can notify the DAP
// Layer of a communication failure for client cleanup purposes.
//!!
#define DAPSERVICEREQUEST 0x0100
#define DAPSERVICEREPLY 0x0200
#define DAPSERVICEBROADCAST 0x0300
//
// The following constants define the actual function numbers of the
// various protocol packets supported by the application.
//
#define DAPLOCATESERVER 0x1001
#define DAPADVERTISESERVER 0x1002
#define DAPALLOCATESESSION 0x1010
#define DAPDEALLOCATESESSION 0x1011
#define DAPADDOPERANDS 0x1012
#define DAPSUBTRACTOPERANDS 0x1013
#define DAPMULTIPLYOPERANDS 0x1014
#define DAPDIVIDEOPERANDS 0x1015
#define DAPRESETCALCULATOR 0x1016
#define DAPSTOREVALUE 0x1017
#define DAPRECALLVALUE 0x1018
//
// The following constants define the error codes returned by DAP APIs
//
// Negative values reflect DAP request/reply processing errors as well
// as CP failures. When the application receives one of these errors,
// it may need to re-establish communications with the application
// server.
//
// Positive values are those which should be acted upon by the application.
// Things like "DIVIDE_BY_ZERO", "NUMERIC_OVERFLOW" and the like. These
// types of errors are non-critical in nature, and the connection status
// remains intact.
//
// Remember to update DAPERR.C if you add new error codes.
//
#define DAP_SUCCESS 0
#define DAP_CRITICAL_ERROR(x) (x<DAP_LOW_FATAL_ERROR&&x>DAP_HI_FATAL_ERROR)
#define DAP_LOW_FATAL_ERROR (-0x700)
#define DAP_CANT_FIND_SERVER (-0x701)
#define DAP_CANT_CONNECT (-0x702)
#define DAP_PACKET_OUT_OF_SEQ (-0x703)
#define DAP_SEND_FAILURE (-0x704)
#define DAP_INVALID_REQUEST (-0x705)
#define DAP_INITFAILED (-0x706)
#define DAP_RESOURCE_ERROR (-0x707)
#define DAP_INTERNAL_ERROR (-0x708)
#define DAP_TIMEOUT (-0x709)
#define DAP_HI_FATAL_ERROR (-0x7ff)
#define DAP_DIVIDE_BY_ZERO 0x701
#define DAP_NUMERIC_OVERFLOW 0x702
#if !defined(DAPINCLSTRUC)
//
// INCLSTRUC is defined when you want to get the actual structure
// definitions for internal structures. Since this header file is
// included by the layer above here, we can 'hide' the structure
// definition by simply making DAPDATA a void data type. When a module
// is going to reference the structures, it must define INCLSTRUC in
// order to get the actual structures declared.
//
typedef void DAPDATA;
#else
//
// The following structures define the packet layout exchanged between
// the client and server DAP layer. In the data portion, the layout
// is defined by each individual DAP.
//
typedef struct {
UINT32 packetType; // whether to/from server
UINT32 sequence; // sequence number of request
UINT32 sessionID; // client session number
UINT32 timesTried; // number of times we've resent this
UINT32 requestCode; // function request code
UINT8 data[DAPMAXDATA]; // the actual data
}DAPRequest;
typedef struct {
UINT32 packetType; // whether to/from server
UINT32 sequence; // sequence number of reply
UINT32 returnCode; // function return code
UINT8 data[DAPMAXDATA]; // the actual data
UINT32 dummy[2]; // keep structures the same length
}DAPReply;
#if !defined(ENGINE)
//
// The following structure is used on the client side to keep track of
// the DAP operations. DAPAllocateSession returns a pointer to one of
// these, and all subsequent DAP requests made by the client application
// pass the pointer to the API.
//
typedef struct {
void *CPid; // data for comm proto layer
UINT32 sessionID; // id between client server DAP Layer
UINT16 retryCount; // retry count for this session
UINT16 responseDelay; // units to wait for a reply
UINT16 timesTried; // number of times we sent duplicate msg
UINT16 sendFailed; // number of times the actual send failed
char serverName[48];
UINT32 nextSequence; // next sequence number to use
DAPRequest dapRequest;
DAPReply dapReply;
}DAPDATA;
#else // !defined(ENGINE)
//
// The following structure is used on the server side to keep track of
// a DAP session. An array of these is maintained by the server application
// for each active session in progress.
//
typedef struct _dd{
//
// These linked-list pointers are used to queue up requests. When
// the client sends in a request, the DAP layer queues this struct
// onto a linked list for processing by a separate thread. These
// pointers are also used for queueing up this structure for an
// outgoing message.
//
struct _dd *next; // pointer to next one in link
struct _dd *prev; // pointer to previous link
//
// The CPid is obtained from the CP Layer when a new session is
// established between the client and server. This id is used
// by the DAP layer when sending replies to the client.
//
UINT32 CPid; // client id for comm proto layer
//!!
// Need to be able to turn this state thing off!
//!!
// Field: DAPState
// Type: UINT32
// This field is used to provide state information for this
// client. It is a bit field, whose definition is:
//
// INUSE 0x1
// - This DAP is currently in use servicing a client request.
//
// RQSTQUEUE 0x2
// - This DAP is sitting in the request queue.
//
// DAP_RECEIVING 0x4
// - The DAP is being processed by ServiceRequestQueue
//
// DAP_SERVICE 0x8
// - This DAP is active in DAPDispatchRequestAPI()
//
// DAP_SENDQUEUE 0x10
// - The DAP is sitting in the send queue.
//
// DAP_SENDING 0x20
// - The DAP is being serviced inside ServiceReplyQueue
//
// DAP_CLIENTLOGIN 0x40
// - The DAP has had a successful login to the engine
//
// DAP_SLOTINUSE 0x8000
// - This DAP is currently in use by a client. Used when
// we are trying to locate an emply slot in the DAP array.
//
#define DAP_INUSE 0x1
#define DAP_RQSTQUEUE 0x2
#define DAP_RECEIVING 0x4
#define DAP_SERVICE 0x8
#define DAP_SENDQUEUE 0x10
#define DAP_SENDING 0x20
#define DAP_CLIENTLOGIN 0x40
#define DAP_SLOTINUSE 0x8000
//
// Macros to manipulate the DAPState field
//
#define DAPStateON(x,y) ((x)->DAPState |= y)
#define DAPStateOFF(x,y) ((x)->DAPState &= ~y)
#define DAPStateActive(x,y) ((x)->DAPState & y)
#define DAPInUse(x) ((x)->DAPState & DAP_INUSE)
#define DAPSlotInUse(x) ((x)->DAPState & DAP_SLOTINUSE)
//
// And finally, the definition of DAPState
//
UINT32 DAPState;
//
// Field: DAPFlags
// Type: UINT32
// This field by whatever mechanisms need flags...
//
// DAP_FREE_THIS_SLOT 0x1
// - Used by the DeAllocateSession DAP to tell the
// ServiceReplyQueue thread to free the slot after
// sending a reply.
//
#define DAP_FREE_THIS_SLOT 0x1
//
// Macros to manipulate the 'flags'
//
#define DAPSetFlag(x,y) ((x)->DAPFlags |= y)
#define DAPReSetFlag(x,y) ((x)->DAPFlags &= ~y)
#define DAPFlagIsSet(x,y) ((x)->DAPFlags & y)
//
// And finally, the definition of flags
//
UINT32 DAPFlags;
//
// Allocate memory for both a dapRequest and dapReply structure
// in here. This provides temporary storage for incoming and
// outgoing requests.
//
DAPRequest dapRequest;
DAPReply dapReply;
//
// We have two options here on the server side.
// 1. define the structure needed by the application
// inside this structure definition.
// 2. have a pointer to the data structure stored only
//
// if we define the structure here, then the DAP APIs will
// be doing all the work themselves when they are called.
// the pointer method would probably be used to call out to
// a different layer (perhaps an application layer) that
// would do some work for us.
//
// if INCDATAAREA is TRUE, we just include the structure in
// this structure.
//
// if INCDATAAREA is FALSE, however, we just define a void ptr.
//
// The source code uses the DAPGetApplDataAreaPtr() macro to
// reference the applData field so it works for both methods.
//
#if INCDATAAREA
#define DAPGetApplDataAreaPtr(x) (&((x)->applData))
#define DAPGetApplDataStructure(x) ((x)->applData)
struct{
SINT32 lastResult;
SINT32 mailBox001;
}applData;
#else
#define DAPGetApplDataAreaPtr(x) ((x)->applData)
void *applData;
#endif
}DAPDATA;
#endif // !defined(ENGINE)
#endif // !defined(DAPINCLSTRUC)
#endif